import { indexDate } from "../../api/index";

Page({
  data: {
    bannerList: [], // 轮播图数据
    categoryList: [], // 商品导航数据
    activeList: [], // 活动渲染区域
    guessList: [], // 猜你喜欢
    hotList: [], // 人气推荐
    loading:true // 是否显示骨架屏
  },

  // 获取首页数据
  async getIndexData() {
    const _this = this;
    const res = await indexDate();
    if (res.length > 0) {
      _this.setData({
        bannerList: res[0].data.data,
        categoryList: res[1].data.data,
        activeList: res[2].data.data,
        guessList: res[3].data.data,
        hotList: res[4].data.data,
        loading:false
      });
    }
  },

  // 转发功能
  onShareAppMessage(){
    return {
      title:"只为你怦然心动",
      path:'/pages/index/index',
      imageUrl:'../../../../../assets/images/love.jpg'
    }
  },

  // 分享朋友圈
  onShareTimeline() {
   return {
     title:"只为你怦然心动",
     path:'/pages/index/index',
     imageUrl:'../../../../../assets/images/love.jpg'
   }
  },

  onLoad() {
    this.getIndexData();
  },
});
